package com.weimob.mcloud.wechatwork.customer.service.check;

import com.weimob.mcloud.wechatwork.customer.service.user.base.BasicInfo;
import com.weimob.mcloud.wechatwork.customer.service.user.exception.BizException;
import com.weimob.mcloud.wechatwork.customer.service.user.module.dto.customer.ExternalUserInfoFindDTO;
import com.weimob.mcloud.wechatwork.customer.service.user.module.dto.customer.MarkTagInfoDTO;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * @author junlong.lv
 * @version 1.0
 * @date 2022/8/4 10:27 上午
 */
public class MarkTagTaskCheck {

    public static void checkMarkTag(ExternalUserInfoFindDTO externalUserInfoListDTO, Integer size) {

        if (null == size) {
            size = 200;
        }

        if (null == externalUserInfoListDTO) {
            throw new BizException("参数不允许为空");
        }

        BasicInfo basicInfo = externalUserInfoListDTO.getBasicInfo();
        if (null == basicInfo || null == basicInfo.getBosId()) {
            throw new BizException("bosId不允许为空");
        }

        List<Long> assignWidList = externalUserInfoListDTO.getAssignWidList();
        if (CollectionUtils.isNotEmpty(assignWidList) && assignWidList.size() > size) {
            throw new BizException("勾选客户超过限制");
        }

        List<Long> removeWidList = externalUserInfoListDTO.getRemoveWidList();
        if (CollectionUtils.isNotEmpty(removeWidList) && removeWidList.size() > size) {
            throw new BizException("移除指定客户勾选超过限制");
        }

        if (CollectionUtils.isNotEmpty(assignWidList) && CollectionUtils.isNotEmpty(removeWidList)) {
            throw new BizException("参数不合法");
        }
    }

    public static void checkQueryMarkTagTask(MarkTagInfoDTO markTagInfoDTO) {
        if (null == markTagInfoDTO) {
            throw new BizException("参数不允许为空");
        }

        if (null == markTagInfoDTO.getBosId()) {
            throw new BizException("bosId不允许为空");
        }

        if (null == markTagInfoDTO.getBwid()) {
            throw new BizException("B端wid不允许为空");
        }

    }

    public static void checkRead(MarkTagInfoDTO markTagInfoDTO) {
        if (null == markTagInfoDTO) {
            throw new BizException("参数不允许为空");
        }

        if (null == markTagInfoDTO.getBosId()) {
            throw new BizException("bosId不允许为空");
        }

        if (null == markTagInfoDTO.getBwid()) {
            throw new BizException("B端wid不允许为空");
        }

        if (null == markTagInfoDTO.getTaskId()) {
            throw new BizException("任务taskId不允许为空");
        }
    }

    public static void checkFetchCount(MarkTagInfoDTO markTagInfoDTO) {
        if (null == markTagInfoDTO) {
            throw new BizException("参数不允许为空");
        }

        if (null == markTagInfoDTO.getBosId()) {
            throw new BizException("bosId不允许为空");
        }

        if (null == markTagInfoDTO.getTaskId()) {
            throw new BizException("任务taskId不允许为空");
        }
    }

    public static void checkQueryMarkTagFailInfoExport(MarkTagInfoDTO markTagInfoDTO) {
        if (null == markTagInfoDTO) {
            throw new BizException("参数不允许为空");
        }

        if (null == markTagInfoDTO.getBosId()) {
            throw new BizException("bosId不允许为空");
        }

        if (null == markTagInfoDTO.getTaskId()) {
            throw new BizException("任务taskId不允许为空");
        }
    }
}
